package com.juku2024.juku.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.juku2024.juku.fragment.CategoryFragment
import com.juku2024.juku.fragment.HomeFragment
import com.juku2024.juku.fragment.MeFragment
import com.juku2024.juku.fragment.MoreFragment
import com.juku2024.juku.fragment.RankingFragment

class HomeBottomFragmentAdapter(activity: FragmentActivity) : FragmentStateAdapter(activity) {

    private val fragments = arrayListOf(HomeFragment(), CategoryFragment(), RankingFragment(), MoreFragment(), MeFragment())
    val tabNames by lazy { arrayOf("首页", "大陆", "榜单", "其他", "我的") }

    fun getHomeFragment(): HomeFragment {
        return fragments.first() as HomeFragment
    }

    override fun getItemCount(): Int {
        return fragments.size
    }

    override fun createFragment(position: Int): Fragment {
        return fragments[position]
    }

}

